<template>
  <div class="youke">
    <van-nav-bar
      :title="$route.query.pay|payText(0)"
      left-arrow
      fixed
      @click-left="onBack('/user/payment')"
    ></van-nav-bar>
    <Main>
      <template slot="main">
        <template v-if="$route.query.pay==1||$route.query.pay==2">
          <div class="show-img">
            <img
              :src='payImg'
              alt
            >
          </div>
        </template>
        <template v-else-if="$route.query.pay==3">
         <div class="inputs-group">
            <van-field v-model="banknName" clearable readonly label="持卡人" placeholder="请输入开户人姓名"/>
            <van-field v-model="bankaddres" label="卡户银行" readonly placeholder="请输入卡户银行"/>
            <!--  right-icon="arrow" readonly @click="show=true" -->
            <van-field v-model="bankcard" clearable label="卡号" readonly placeholder="请输入卡号"/>
          </div>
        </template>
        <template v-else>暂无内容</template>
      </template>
    </Main>
  </div>
</template>

<script type="text/ecmascript-6">
import {user} from '@/api'
export default {
  //接收父级传递的参数
  props: [],
  //监听数据变化
  watch: {},
  data() {
    return {
      payImg:"",
      banknName:"",
      bankaddres:"",
      bankcard:""
    };
  },
  //实例初始化之前触发事件
  beforeCreate() {},
  //实例化之后触发事件
  created() {},
  //实时监控data参数数据变化
  computed: {},
  //模板组件
  components: {},
  //执行方法
  methods: {
     getlist() {
      user.bindpay({type:this.$route.query.pay}).then(res => {
        if (res.code == 1000) {
          if(this.$route.query.pay==3){
            this.banknName=res.result[0]
            this.bankaddres=res.result[1]
            this.bankcard=res.result[2]
          }else{
            this.payImg=res.result
          }

        }
      });
    }
  },
  filters: {
    payText(value, t) {
      let name = `微信${t == 0 ? "绑定" : ""}`;
      switch (value) {
        case "1":
          name = `微信${t == 0 ? "绑定" : ""}`;
          break;
        case "2":
          name = `支付宝${t == 0 ? "绑定" : ""}`;
          break;
        case "3":
          name = `银行卡${t == 0 ? "绑定" : ""}`;
          break;

        default:
          name = `微信${t == 0 ? "绑定" : ""}`;
          break;
      }
      return name;
    }
  },
  mounted() {
      console.log('payments');
    this.getlist()
  }
  //路由退出时候调用
  //beforeRouteLeave(to, from, next){next()}
};
</script>

<style scoped lang="less">
.show-img {
  width: 100%;
  height: 100%;
  img {
    width: 100%;
  }
}
</style>
